document.addEventListener('DOMContentLoaded', function() {
    var cartdetail = document.querySelector('.wrapper .cart-detail');
    var cartleft = document.querySelector('.wrapper .cart .cart-left');
   
    // 点击购物车左侧显示购物车
    cartleft.addEventListener('click', function(event) {
      event.stopPropagation(); // 阻止事件冒泡
      if(cartdetail.style.display=='block'){
        cartdetail.style.display = 'none';
        
      }
        
      
    else{ 
      cartdetail.style.display = 'block';
     }
   
      
    });
  
    // 点击购物车任何地方不关闭
    cartdetail.addEventListener('click', function(event) {
      event.stopPropagation(); // 阻止事件冒泡
    });
  
    // 点击购物车外部区域关闭购物车
    document.addEventListener('click', function() {
       
      if (cartdetail.style.display === 'block') {
        cartdetail.style.display = 'none';
      }
    });
  });